Skip to content

IDEA-387204 bookmarks: sync line numbers after document reload#3461

Open
fvoidhe wants to merge 1 commit intoJetBrains:masterfrom
fvoidhe:fix/bookmark-line-sync
Open

IDEA-387204 bookmarks: sync line numbers after document reload#3461
fvoidhe wants to merge 1 commit intoJetBrains:masterfrom
fvoidhe:fix/bookmark-line-sync

Conversation

@fvoidhe
Copy link
Copy Markdown

@fvoidhe fvoidhe commented Mar 18, 2026

When a file is reloaded from disk, beforeFileContentReload adds the document to reloadingDocs, causing afterDocumentChange to skip all intermediate notifications during the reload — which is intentional (IJPL-62074). However, once fileContentReloaded fires and the document is removed from the set, afterDocumentChange was never called to reconcile the final state.

During reload the platform updates RangeMarkers to reflect new line positions, so the editor gutter shows bookmark icons at the correct (shifted) lines. But LineBookmarkImpl.line was never updated, leaving the stored line number stale. This caused the Bookmarks tool window to display the old line number while the gutter marker appeared at the new one.

Fix: call afterDocumentChange(document) at the end of fileContentReloaded, after removing the document from reloadingDocs, so the guard no longer blocks it and bookmark line numbers are resynced with the post-reload RangeMarker positions.


Note

Low Risk
Low risk: a small change to bookmark synchronization that runs only after fileContentReloaded, with minimal surface area outside the bookmarks subsystem.

Overview
Fixes stale line numbers for line bookmarks after a document is reloaded from disk.

LineBookmarkProvider now calls afterDocumentChange(document) at the end of FileDocumentManagerListener.fileContentReloaded, ensuring stored LineBookmarkImpl.line values are reconciled with the post-reload RangeMarker positions (so the Bookmarks tool window matches gutter markers).

Written by Cursor Bugbot for commit 05d2f5b. This will update automatically on new commits. Configure here.

When a file is reloaded from disk, `beforeFileContentReload` adds the
document to `reloadingDocs`, causing `afterDocumentChange` to skip all
intermediate notifications during the reload — which is intentional
(IJPL-62074). However, once `fileContentReloaded` fires and the document
is removed from the set, `afterDocumentChange` was never called to
reconcile the final state.

During reload the platform updates RangeMarkers to reflect new line
positions, so the editor gutter shows bookmark icons at the correct
(shifted) lines. But `LineBookmarkImpl.line` was never updated, leaving
the stored line number stale. This caused the Bookmarks tool window to
display the old line number while the gutter marker appeared at the
new one.

Fix: call `afterDocumentChange(document)` at the end of
`fileContentReloaded`, after removing the document from `reloadingDocs`,
so the guard no longer blocks it and bookmark line numbers are resynced
with the post-reload RangeMarker positions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants